DROP VIEW [dbo].[LocalSchemaVersion]
GO

CREATE VIEW [dbo].[LocalSchemaVersion] AS
SELECT 6 AS VersionNumber
GO

CREATE TABLE [dbo].[OutputMirror](
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [Name] [varchar](200) NOT NULL,
	[Source] [varchar](max) NOT NULL,
	[ConnectionType] [varchar](200) NOT NULL,
    [Settings] [varchar](max) NULL,
    [LoadOrder] [int] NOT NULL CONSTRAINT [DF_OutputMirror_LoadOrder] DEFAULT ((0)),
    [CreatedOn] [datetime] NOT NULL CONSTRAINT [DF_OutputMirror_CreatedOn] DEFAULT (getutcdate()),
    [CreatedBy] [varchar](200) NOT NULL CONSTRAINT [DF_OutputMirror_CreatedBy] DEFAULT (suser_name()),
    [UpdatedOn] [datetime] NOT NULL CONSTRAINT [DF_OutputMirror_UpdatedOn] DEFAULT (getutcdate()),
    [UpdatedBy] [varchar](200) NOT NULL CONSTRAINT [DF_OutputMirror_UpdatedBy] DEFAULT (suser_name()),
 CONSTRAINT [PK_OutputMirror] PRIMARY KEY CLUSTERED
(
    [ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO

CREATE TABLE IONWaveformCheckpoint
(
    ID INT IDENTITY(1, 1) NOT NULL PRIMARY KEY,
    Device VARCHAR(200) NOT NULL,
    TimeRecorded DATETIME2 NOT NULL,
    LogPositions VARCHAR(MAX) NOT NULL DEFAULT '[]',
    CONSTRAINT IX_IONWaveformCheckpoint_Device UNIQUE (Device ASC, TimeRecorded ASC)
)
GO

CREATE TABLE IONTrendingCheckpoint
(
    ID INT IDENTITY(1, 1) NOT NULL PRIMARY KEY,
    Device VARCHAR(200) NOT NULL,
    TimeRecorded DATETIME NOT NULL,
    LogPositions VARCHAR(MAX) NOT NULL DEFAULT '[]',
    CONSTRAINT IX_IONTrendingCheckpoint_Device UNIQUE (Device ASC, TimeRecorded ASC)
)
GO